/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.coraci.bas.ws;

import javax.ejb.EJB;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;
import javax.jws.Oneway;
import org.coraci.bas.db.BankFacade;
import org.coraci.bas.db.entities.Bank;

/**
 *
 * @author Luca
 */
@WebService(serviceName = "BankWS")
@Stateless()
public class BankWS {
    @EJB
    private BankFacade bankFacade;

    /**
     * This is a sample web service operation
     */
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        System.out.println("Server side: Hello "+txt);
        return "Hello " + txt + " !";
    }

    /**
     * Web service operation
     */
    @WebMethod(operationName = "createBank")
    @Oneway
    public void createBank(@WebParam(name = "name") String name) {
        System.out.println("Creating Bank........ with name : "+name);
        Bank bank = new Bank();
        bank.setDenominazione(name);
        bankFacade.create(bank);
        System.out.println("Bank Created, id = "+bank.getId());
    }
}
